package GUI.Usuario;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;

import BBDD.ManageModulo;
import BBDD.ManageNotasAlumno;
import BBDD.ManageNotasParcialAlumno;
import DAO.NotaAlumnoDAO;
import DAO.NotaParcialAlumnoDAO;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Vector;

public class DiarioNotas extends JFrame {

	private JPanel contentPane;
	private JTable table;
	private JButton btnAadirNota;
	private JButton btnVolver;
	private Vector<NotaParcialAlumnoDAO> notaParcial;
	private ManageNotasParcialAlumno controladorBD;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DiarioNotas frame = new DiarioNotas();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public DiarioNotas() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 539, 342);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);

		JScrollPane scrollPane = new JScrollPane();

		btnAadirNota = new JButton("Validar");
		btnAadirNota.setIcon(new ImageIcon(DiarioNotas.class
				.getResource("/Utilidades/Check.png")));
		btnAadirNota.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				controladorBD = new ManageNotasParcialAlumno();

				String query="INSERT INTO nota_parcial_alumno VALUES (1,1,1,1,12,12,7)";
				
				
				controladorBD.updateNotaParcialAlumno(query);

			}
		});

		btnVolver = new JButton("Volver");
		btnVolver.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dispose();
			}
		});
		btnVolver.setIcon(new ImageIcon(DiarioNotas.class
				.getResource("/Utilidades/volver.png")));
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane
				.setHorizontalGroup(gl_contentPane
						.createParallelGroup(Alignment.TRAILING)
						.addGroup(
								gl_contentPane
										.createSequentialGroup()
										.addGroup(
												gl_contentPane
														.createParallelGroup(
																Alignment.TRAILING)
														.addComponent(
																scrollPane,
																GroupLayout.DEFAULT_SIZE,
																503,
																Short.MAX_VALUE)
														.addGroup(
																gl_contentPane
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				btnAadirNota)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				btnVolver,
																				GroupLayout.PREFERRED_SIZE,
																				104,
																				GroupLayout.PREFERRED_SIZE)))
										.addContainerGap()));
		gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(
				Alignment.LEADING).addGroup(
				gl_contentPane
						.createSequentialGroup()
						.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE,
								220, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(ComponentPlacement.UNRELATED)
						.addGroup(
								gl_contentPane
										.createParallelGroup(Alignment.LEADING)
										.addComponent(btnAadirNota,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addComponent(btnVolver,
												GroupLayout.DEFAULT_SIZE, 45,
												Short.MAX_VALUE)).addGap(21)));

		table = new JTable();
		table.setModel(new DefaultTableModel(new Object[][] {
				{ null, null, null }, { null, null, null },
				{ null, null, null }, { null, null, null },
				{ null, null, null }, { null, null, null },
				{ null, null, null }, { null, null, null },
				{ null, null, null }, { null, null, null },
				{ null, null, null }, { null, null, null },
				{ null, null, null }, { null, null, null },
				{ null, null, null }, { null, null, null }, }, new String[] {
				"Evaluacion", "Trabajo", "Nota" }));
		table.getColumnModel().getColumn(0).setPreferredWidth(68);
		table.getColumnModel().getColumn(1).setPreferredWidth(424);
		table.getColumnModel().getColumn(2).setPreferredWidth(65);
		scrollPane.setViewportView(table);
		contentPane.setLayout(gl_contentPane);
	}

	public void fillTable() {
		controladorBD = new ManageNotasParcialAlumno();
		controladorBD
				.loadNotaParcialAlumno("Select * from nota_parcial_alumno");
		notaParcial = controladorBD.getNotaParcialAlumno();
		for (int i = 0; i < notaParcial.size(); i++) {
			System.out.println(notaParcial.get(i).getEvaluacionNotaParcial());
		System.out.println(notaParcial.get(i).getIdTipoNotaParcial());
		System.out.println(notaParcial.get(i).getIdNotaParcialAlumno());
		}
		

	}

}
